<template>
    <div class="">
        <el-dialog title="编辑重点个人" :visible.sync="dialog" width="40%" :before-close="dialogClose">
            <el-form ref="formData" :model="formData" label-width="100px">
				<el-form-item label="个人信息" prop="userid">
				    <el-select filterable v-model="formData.userid" style="width: 100%;" placeholder="请选择个人信息">
				    	<el-option :label="item.name" :value="item.id" v-for="(item, index) in User"></el-option>
				    </el-select>
				</el-form-item>
				<el-form-item label="残疾证号" prop="sn">
					<el-input v-model="formData.sn" placeholder="请输入残疾证号"></el-input>
				</el-form-item>
				<el-form-item label="电话" prop="phone">
					<el-input v-model="formData.phone" placeholder="请输入电话"></el-input>
				</el-form-item>
				<!-- <el-row> -->
<!-- 					<el-col :span="12">
						<el-form-item label="姓名" prop="name">
							<el-input v-model="formData.name" placeholder="请输入姓名"></el-input>
						</el-form-item>
					</el-col> -->
	<!-- 				<el-col :span="12">
						<el-form-item label="电话" prop="phone">
							<el-input v-model="formData.phone" placeholder="请输入电话"></el-input>
						</el-form-item>
					</el-col>
				</el-row> -->
				
				
				<el-row>
					<el-col :span="12">
						<el-form-item label="返贫监测户" prop="back_user">
							<el-select v-model="formData.back_user" style="width: 100%;" placeholder="请选择返贫监测户">
								<el-option :label="item" :value="item" v-for="(item, index) in Site.commonTag"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="家庭地址" prop="addr">
							<el-input v-model="formData.addr" placeholder="请输入家庭地址"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				
				<el-row>
					<el-col :span="12">
						<el-form-item label="类别" prop="cate">
							<el-select v-model="formData.cate" style="width: 100%;" placeholder="请选择所属类别">
								<el-option :label="item" :value="item" v-for="(item, index) in Site.userCate"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="就业状况" prop="employed">
							<el-select v-model="formData.employed" style="width: 100%;" placeholder="请选择就业状况">
								<el-option :label="item" :value="item" v-for="(item, index) in Site.personEmployed"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				
				<el-row>
					<el-col :span="12">
						<el-form-item label="排查方式" prop="searched">
							<el-select v-model="formData.searched" style="width: 100%;" placeholder="请选择排查方式">
								<el-option :label="item" :value="item" v-for="(item, index) in Site.searched"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="排查时间" prop="searched_date">
							<el-date-picker
								style="width: 100%;"
								v-model="formData.searched_date"
								type="date"
								format="yyyy-MM-dd"
								value-format="yyyy-MM-dd"
								placeholder="选择日期">
							</el-date-picker>
						</el-form-item>
					</el-col>
				</el-row>

				<el-row>
					<el-col :span="12">
						<el-form-item label="就学情况" prop="study">
						    <el-select v-model="formData.study" style="width: 100%;" placeholder="请选择就学情况">
						    	<el-option :label="item" :value="item" v-for="(item, index) in Site.personStudy"></el-option>
						    </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="家庭成员" prop="member">
						    <el-input v-model="formData.member" placeholder="请输入家庭成员">
								<template slot="append">人</template>
							</el-input>
						</el-form-item>
					</el-col>
				</el-row>
				
				<el-row>
					<el-col :span="12">
						<el-form-item label="医疗保险" prop="medical">
						    <el-select v-model="formData.medical" style="width: 100%;" placeholder="请选择医疗保险">
						    	<el-option :label="item" :value="item" v-for="(item, index) in Site.commonJoin"></el-option>
						    </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="代缴医疗" prop="medical_flag">
						    <el-select v-model="formData.medical_flag" style="width: 100%;" placeholder="请选择代缴医疗">
						    	<el-option :label="item" :value="item" v-for="(item, index) in Site.commonFlag"></el-option>
						    </el-select>
						</el-form-item>
					</el-col>
				</el-row>
				
				<el-row>
					<el-col :span="12">
						<el-form-item label="养老保险" prop="provide">
						    <el-select v-model="formData.provide" style="width: 100%;" placeholder="请选择医疗保险">
						    	<el-option :label="item" :value="item" v-for="(item, index) in Site.commonJoin"></el-option>
						    </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="代缴养老" prop="provide_flag">
						    <el-select v-model="formData.provide_flag" style="width: 100%;" placeholder="请选择代缴养老">
						    	<el-option :label="item" :value="item" v-for="(item, index) in Site.commonFlag"></el-option>
						    </el-select>
						</el-form-item>
					</el-col>
				</el-row>
				
				<el-row>
					<el-col :span="12">
						<el-form-item label="纳入低保" prop="allowance">
						    <el-select v-model="formData.allowance" style="width: 100%;" placeholder="请选择医疗保险">
						    	<el-option :label="item" :value="item" v-for="(item, index) in Site.commonTag"></el-option>
						    </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="特困供养" prop="destitute">
						    <el-select v-model="formData.destitute" style="width: 100%;" placeholder="请选择代缴养老">
						    	<el-option :label="item" :value="item" v-for="(item, index) in Site.commonTag"></el-option>
						    </el-select>
						</el-form-item>
					</el-col>
				</el-row>
				
				<el-row>
					<el-col :span="12">
						<el-form-item label="生活补贴" prop="living">
						    <el-select v-model="formData.living" style="width: 100%;" placeholder="请选择医疗保险">
						    	<el-option :label="item" :value="item" v-for="(item, index) in Site.commonTag"></el-option>
						    </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="护理补贴" prop="nursing">
						    <el-select v-model="formData.nursing" style="width: 100%;" placeholder="请选择代缴养老">
						    	<el-option :label="item" :value="item" v-for="(item, index) in Site.commonTag"></el-option>
						    </el-select>
						</el-form-item>
					</el-col>
				</el-row>

            	<el-form-item>
            		<el-button @click="dialogClose">取 消</el-button>
            		<el-button type="primary" @click="formSubmit">确 定</el-button>
            	</el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>
<script>
export default {
	components: {
	},
	data() {
		return {
			dialog: false,
			Site: [],
			User: [],
			Hamlet: [],
			formData: {
				id: 0,
				sn: '', //残疾证号
				userid: '', //所属个人
				name: '', //姓名
				phone: '', //电话
				cate: '', //类别
				searched: '', //排查方式 
				searched_date: '', //排查时间 
				back_user: '', //是否为防返贫监测户
				addr: '', //家庭地址
				employed: '', //就业状况 
				study: '', //就学情况
				member: '', //家庭成员数量
				medical: '', //医疗状况
				medical_flag: '',//代缴医疗
				provide: '', //养老状况
				provide_flag: '', //代缴养老
				allowance: '', //低保
				destitute: '', //特困
				living: '', //生活补贴
				nursing: '', //护理补贴
			},
		}
	},
	created() {
	},
	watch: {
		dialog () {
			if(!this.dialog) {
				this.clearFormData()
				this.$emit('getData')
			} else {
				this.getUser()
				this.getSite()
			}
		}
	},
	methods: {
		getUser () {
			this.$apiPost('User/getUser').then(res => {
				if(res.code == 1) {
					this.User = res.data
				}
			})
		},
		getSite () {
			this.$apiPost('Index/getSiteFile').then(res => {
				if(res.code == 1) {
					this.Site = res.data
				}
			})
		},
		dialogClose(){
			this.$emit('dialogToggle')
		},
		clearFormData () {
			for(let i in this.formData){
				if(i == 'id') {
					this.formData[i] = 0
				} else {
					this.formData[i] = ''
				}
			}
		},
		// 保存编辑
		formSubmit() {
			this.$apiPost('Person/editData', this.formData).then(res => {
				if(res.code == 1) {
					this.$message(res.msg)
					this.dialogClose()
				} else {
					this.$message(res.msg)
				}
			})
		},
	}
}
</script>
<style scoped>
	.mselect{
		width: 100%;
	}
	.mtdiv{
		margin-top: 10px;
		display: inline-block;
		width: 100%;
	}
	.mtdiv .mtdiv-v{
		float: left;
		width: 50%;
		margin-bottom: 5px;
		display: flex;
		align-items: center;
	}
	.mtdiv .mtdiv-v label{
		float: left;
		margin-right: 10px;
	}
	.mtdiv .el-input{
		float: left;
		width: 80%;
		margin: 5px 0;
	}
	.el-cascader {
		line-height: 32px !important;
	}
	.el-input__inner {
	    height: 32px !important;
	    line-height: 32px !important;
	}
	.el-input__icon {
		line-height: 32px !important;
	}
</style>
